class Solution
{
public:
    int MLS(vector<int>& arr)
    {
        sort(arr.begin(), arr.end());
        int n = arr.size(), ret = 0;
        for(int i = 0; i < n; )
        {
            int j = i + 1, count = 1;
            while(j < n)
            {
                if(arr[j] - arr[j - 1] == 1)
                {
                    count++;
                    j++;
                }
                else if(arr[j] - arr[j - 1] == 0)
                {
                    j++;
                }
                else
                {
                    break;
                }
            }
            ret = max(ret, count);
            i = j;
        }
        return ret;
    }
};